package graphlib;

import java.util.*;

/**
 *
 * @author ITU-KF04-2011, Group 11
 */
public class CombinedIterator<T> implements Iterator{
    private Iterator<T>[] its;

    CombinedIterator(Iterator[] iterators){
        its = iterators;
    }

    public boolean hasNext() {
        for(int i=0; i<its.length; i++)
            if(its[i].hasNext()) return true;
        return false;
    }

    public T next() {
        for(int i=0; i<its.length; i++)
            if(its[i].hasNext()) return its[i].next();
        return its[0].next();
    }

    public void remove() {
        throw new UnsupportedOperationException("Not supported by the combined iterator..");
    }
}
